<?php
/**
 * Created by PhpStorm.
 * User: qishengqiang
 * Date: 2022-08-03
 * Time: 15:03
 */

namespace app\services;


use app\models\ActivityEnlists;

class ActivityEnlistService extends ServiceBase
{
    /**
     * @param array $params
     * @param int $page
     * @param int $pagesize
     * @return \think\Paginator
     * @throws \think\db\exception\DbException
     */
    public function getLists($params=[], $page=1, $pagesize=10)
    {
        return ActivityEnlists::lists($params, $page, $pagesize);
    }

    /**
     * @param $params
     * @return bool
     * @throws \Exception
     */
    public function add($params)
    {
        try {
            $activity = new ActivityEnlists();

            foreach ($params as $key => $val) {
                $activity->$key = $val;
            }
            $activity->save();

            return true;
        } catch (\Exception $e) {
            throw new \Exception($e->getMessage(), 500);
        }
    }
}